﻿using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using LiveCharts;
using LiveCharts.Wpf;

namespace ICAM.View
{
    public partial class CustomersTooltip : IChartTooltip
    {
        private TooltipData _data;

        public CustomersTooltip()
        {
            InitializeComponent();

            DataContext = this; 
        }

        public void Update()
        {
            if (_data != null)
            {
                if (_data.SharedValue == 2)
                {
                    AngleBorder.Placement = EnumPlacement.RightCenter;
                }
                else
                {
                    AngleBorder.Placement = EnumPlacement.LeftCenter;
                }

                this.AngleBorder.InvalidateVisual();
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public TooltipData Data
        {
            get { return _data; }
            set
            {
                _data = value;
                OnPropertyChanged("Data");
            }
        }

        public TooltipSelectionMode? SelectionMode { get; set; }

        protected virtual void OnPropertyChanged(string propertyName = null)
        {
            if (PropertyChanged != null)
                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
